<?php
declare(strict_types=1);
namespace Field;

class AuthKeywordConst
{
    public const pk='KeyWordID';
    public const index=['KeyWordID'];
	public const fields=['KeyWordID','KeyWord','AvgPrice','Ymd','ClickThroughRate','SimWeight','TmaoClickRatio','SeIpvUvHits','PayConvRate','PayByrCnt'];
	public const comment=['KeyWordID'=>'关键词ID','KeyWord'=>'关键词','AvgPrice'=>'均价','Ymd'=>'Ymd','ClickThroughRate'=>'点击率  1.2','SimWeight'=>'需求供给比 239.16','TmaoClickRatio'=>'天猫商品点击比  0.58085','SeIpvUvHits'=>'搜索人气 100万 ~ 250万','PayConvRate'=>'支付转化率 10% ~ 15%','PayByrCnt'=>'支付买家数 5万 ~ 10万'];
	/*
    * @Field KeyWordID
    * @Type bigint(11) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 关键词ID
    */
    public const KeyWordID = 'KeyWordID';
    /*
    * @Field KeyWord
    * @Type varchar(32)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key MUL
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 关键词
    */
    public const KeyWord = 'KeyWord';
    /*
    * @Field AvgPrice
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 均价
    */
    public const AvgPrice = 'AvgPrice';
    /*
    * @Field Ymd
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment Ymd
    */
    public const Ymd = 'Ymd';
    /*
    * @Field ClickThroughRate
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 点击率  1.2
    */
    public const ClickThroughRate = 'ClickThroughRate';
    /*
    * @Field SimWeight
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 需求供给比 239.16
    */
    public const SimWeight = 'SimWeight';
    /*
    * @Field TmaoClickRatio
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 天猫商品点击比  0.58085
    */
    public const TmaoClickRatio = 'TmaoClickRatio';
    /*
    * @Field SeIpvUvHits
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 搜索人气 100万 ~ 250万
    */
    public const SeIpvUvHits = 'SeIpvUvHits';
    /*
    * @Field PayConvRate
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 支付转化率 10% ~ 15%
    */
    public const PayConvRate = 'PayConvRate';
    /*
    * @Field PayByrCnt
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 支付买家数 5万 ~ 10万
    */
    public const PayByrCnt = 'PayByrCnt';
}

class AuthKeywordColumns
{
public  int $KeyWordID;
   public  string $KeyWord;
   public  int $AvgPrice=0;
   public  int $Ymd=0;
   public  int $ClickThroughRate=0;
   public  int $SimWeight=0;
   public  int $TmaoClickRatio=0;
   public  int $SeIpvUvHits=0;
   public  int $PayConvRate=0;
   public  int $PayByrCnt=0;
	public function toArray():array
	{
		return [
'KeyWordID'=>$this->KeyWordID,
    'KeyWord'=>$this->KeyWord,
    'AvgPrice'=>$this->AvgPrice,
    'Ymd'=>$this->Ymd,
    'ClickThroughRate'=>$this->ClickThroughRate,
    'SimWeight'=>$this->SimWeight,
    'TmaoClickRatio'=>$this->TmaoClickRatio,
    'SeIpvUvHits'=>$this->SeIpvUvHits,
    'PayConvRate'=>$this->PayConvRate,
    'PayByrCnt'=>$this->PayByrCnt,        ];
	}
}

class AuthKeywordRow
{
	public AuthKeywordColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'KeyWordID' => $this->data->KeyWordID,
        'KeyWord' => $this->data->KeyWord,
        'AvgPrice' => $this->data->AvgPrice,
        'Ymd' => $this->data->Ymd,
        'ClickThroughRate' => $this->data->ClickThroughRate,
        'SimWeight' => $this->data->SimWeight,
        'TmaoClickRatio' => $this->data->TmaoClickRatio,
        'SeIpvUvHits' => $this->data->SeIpvUvHits,
        'PayConvRate' => $this->data->PayConvRate,
        'PayByrCnt' => $this->data->PayByrCnt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new AuthKeywordColumns();
        isset($data['KeyWordID']) && $this->data->KeyWordID = (int)$data['KeyWordID'];
           isset($data['KeyWord']) && $this->data->KeyWord = (string)$data['KeyWord'];
           isset($data['AvgPrice']) && $this->data->AvgPrice = (int)$data['AvgPrice'];
           isset($data['Ymd']) && $this->data->Ymd = (int)$data['Ymd'];
           isset($data['ClickThroughRate']) && $this->data->ClickThroughRate = (int)$data['ClickThroughRate'];
           isset($data['SimWeight']) && $this->data->SimWeight = (int)$data['SimWeight'];
           isset($data['TmaoClickRatio']) && $this->data->TmaoClickRatio = (int)$data['TmaoClickRatio'];
           isset($data['SeIpvUvHits']) && $this->data->SeIpvUvHits = (int)$data['SeIpvUvHits'];
           isset($data['PayConvRate']) && $this->data->PayConvRate = (int)$data['PayConvRate'];
           isset($data['PayByrCnt']) && $this->data->PayByrCnt = (int)$data['PayByrCnt'];
    }
}
?>